//
//  BNMineController.m
//  BNCodeGuide
//
//  Created by kevin007 on 2020/10/9.
//  Copyright © 2020 kevin007. All rights reserved.
//

#import "BNMineController.h"

#import "BNMineCollectionListView.h"

@interface BNMineController ()<BNBaseCollectionListDelegate>
/** collection list view*/
@property (nonatomic, strong) BNMineCollectionListView *collectionListView;
@end

@implementation BNMineController
- (void)dealloc
{
    NSLog(@"%s", __func__);
}

- (void)viewDidLoad {
    [super viewDidLoad];
   
    [self setupUI];
    [self requestData];
}


#pragma mark - setupUI
- (void)setupUI{
    self.fd_prefersNavigationBarHidden = YES;
    self.view.backgroundColor = [UIColor randomColor];
    
    [self.view addSubview:self.collectionListView];
    [self addLayouts];
}

#pragma mark - ----------------AddLayouts----------------
- (void)addLayouts {
    [self.collectionListView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_offset(0);
    }];
}

#pragma mark - ----------------Request----------------
- (void)requestData {
    //fetch data
    
    [self refreshUI];
}

#pragma mark - ----------------RefreshUI----------------
- (void)refreshUI {
    self.collectionListView.dataSource = @[];
    [self.collectionListView refreshUI];
}

#pragma mark - ----------------BNBaseCollectionListDelegate----------------
- (void)collectionListView:(BNBaseCollectionListView *)listView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"%s", __func__);
}

#pragma mark - ----------------Getter & Setter----------------
- (BNMineCollectionListView *)collectionListView {
    if (!_collectionListView) {
        _collectionListView = [[BNMineCollectionListView alloc] initWithFrame:CGRectZero];
        CGFloat width = floor(UIScreen.width * 0.5);
        _collectionListView.flowLayout.itemSize = CGSizeMake(width, width);
        _collectionListView.delegate = self;
    }
    
    return _collectionListView;
}
@end
